<template>
	<view>
		
	<form @submit="formSubmit" @reset="formReset">
<!-- 		<view class="content">
			<label class="lable">电炉铁水成分标准铜</label>
			<text  class="v_input" >{{bnhjcftjss.cuBz}}</text>
		</view>
		
		<view class="content">
			<label class="lable">电炉铁水成分标准锡</label>
			<text  class="v_input">{{bnhjcftjss.snBz}}</text>
		</view>
		
		<view class="content">
			<label class="lable">电炉铁水成分标准锰</label>
			<text   class="v_input">{{bnhjcftjss.mnBz}}</text>
		</view>
		
		<view class="content">
			<label class="lable">铜粒铜含量</label>
			<text  class="v_input">{{bnhjcftjss.tlCuhl}}</text>
		</view>
		
		<view class="content">
			<label class="lable">铜粒铜吸收率</label>
			<text  class="v_input">{{bnhjcftjss.tlCuxsl}}</text>
		</view>
		<view class="content">
			<label class="lable">锡粒锡含量</label>
			<text class="v_input">{{bnhjcftjss.xlSnhl}}</text>
		</view>
		
		<view class="content">
			<label class="lable">锡粒锡吸收率</label>
			<text class="v_input">{{bnhjcftjss.xlSnxsl}}</text>
		</view>
		<view class="content">
			<label class="lable">锰铁含锰量</label>
			<text class="v_input">{{bnhjcftjss.mtMnhl}}</text>
		</view>
		
		<view class="content">
			<label class="lable">锰铁锰吸收率</label>
			<text  class="v_input">{{bnhjcftjss.mtMnxsl}}</text>
		</view> -->
		<view class="content">
			<label class="lable">牌号:</label>
			<text  name="ph"  class="v_input"  @tap="selectPh()" >{{model.ph}}</text>
		</view>
		<view class="content">
			<label class="lable">包内铁水成分标准硅%:</label>
			<!-- <input type="number" name="cu"  class="v_input"  placeholder="请输入" /> -->
			<text class="v_input">{{this.bnhjcftjss.cuBz}}\n</text>
		</view>
		
		<view class="content">
			<label class="lable">包内铁水成分标准锰%:</label>
			<!-- <input type="number" name="cu"  class="v_input"  placeholder="请输入" /> -->
			<text class="v_input">{{this.bnhjcftjss.mnBz}}\n</text>
		</view>
		
		
		<view class="content">
			<label class="lable">电炉出铁铁水成分Si%:</label>
			<input type="number" name="cu"  class="v_input"  placeholder="请输入" />
		</view>
		
		
		<view class="content">
			<label class="lable">电炉出铁铁水成分Mn%:</label>
			<input type="number" name="mn"  class="v_input"  placeholder="请输入"/>
		</view>
		
		
		<view class="content">
			<label class="lable">包内分包重量(kg):</label>
			<input type="number" name="fbzl"  class="v_input"  placeholder="请输入"/>
		</view>
		
		<view class="break-space"></view>
		<view class="content">
			<label class="lable">包内硅铁粒加入量(kg):</label>
			<label class="result" :style="{ color: textColor }">{{tl}}</label>
		</view>
		
		<view class="content">
			<label class="lable">包内锰铁加入量(kg):</label>
			<label class="result" :style="{ color: textColor }">{{mt}}</label>
		</view>

		<button form-type="submit" class="btn">计算</button>
	</form>
		
	</view>
</template>

<script>
	import configService from '@/common/config.service.js';
	const apiUrl = configService.apiUrl;
	export default {
		data() {
			return {
				bnhjcftjss : null,
				tl : 0,
				xl : 0,
				mt : 0,
				textColor:'black',
				model:{
					deptId:uni.getStorageSync("deptId"),
					type: 3,
					ph:''
				},

				phlist:[]
			}
		},
		onLoad() {
			this.getPhList();
			this.getBnhjcftzssBz();
		},
		onShow:function(e){
			this.$verify.verify();
		},
		methods: {
			getPhList(){
				uni.request({
					url:apiUrl+'/bnhjcftzss/getSsPh',
					header:{
						'content-type':'application/json'
					},
					method:'POST',
					data:this.model,
					success: (res) => {
						if(res.statusCode === 200 &&  res.data.data.length > 0 )
						{
							this.phlist = res.data.data;
						}else{
							uni.showModal({
							    title: '提示',  //提示标题
							    content: '请维护包内合金成分调整标准！',  //提示内容
							    showCancel: true, //是否显示取消按钮
							    success: function (res) {
							        if (res.confirm) {  //confirm为ture，代表用户点击确定
							            console.log('点击了确定按钮');
							        } else if (res.cancel) {  //cancel为ture，代表用户点击取消
							            console.log('点击了取消按钮');
							        }
							    }
							})
							
						}
					}
				})
			},
			selectPh(){
				let _this = this;
				let items = _this.phlist;
				uni.showActionSheet({
					itemList: items,
					success: function (res) {
						_this.model.ph = items[res.tapIndex];
						_this.getBnhjcftzssBz();
					},
					fail: function (res) {
						console.log(res.errMsg);
					}
				});
			},
			getBnhjcftzssBz(){
				uni.request({
					url:apiUrl+'/bnhjcftzss/getSsbz',
					header:{
						'content-type':'application/json'
					},
					method:'POST',
					data:this.model,
					success: (res) => {
						if(res.statusCode === 200 &&  res.data.data.length > 0 )
						{
							this.bnhjcftjss = res.data.data[0];
							this.model.ph = this.bnhjcftjss.ph;
						}else{
							uni.showModal({
							    title: '提示',  //提示标题
							    content: '请维护包内合金成分调整标准！',  //提示内容
							    showCancel: true, //是否显示取消按钮
							    success: function (res) {
							        if (res.confirm) {  //confirm为ture，代表用户点击确定
							            console.log('点击了确定按钮');
							        } else if (res.cancel) {  //cancel为ture，代表用户点击取消
							            console.log('点击了取消按钮');
							        }
							    }
							})
							
						}
					}
				})
			},
			formSubmit(e) {
				var _this = this;
				if(_this.bnhjcftjss == null){
					uni.showToast({
						title: "请先维护包内合金成分速算标准！",
						icon:'error',
						duration:1000
					});
					return ;
				}
				
				let formData = e.detail.value;
				// 标准铜含量
				this.tl = ((this.bnhjcftjss.cuBz-formData.cu)*formData.fbzl/this.bnhjcftjss.tlCuhl/this.bnhjcftjss.tlCuxsl *100).toFixed(2)
				this.mt = ((this.bnhjcftjss.mnBz-formData.mn)*formData.fbzl/this.bnhjcftjss.mtMnhl/this.bnhjcftjss.mtMnxsl *100).toFixed(2)
				this.textColor = '#3E60D2';		
						
			}

		}
	}
</script>

<style>

@import "@/common/susuanht.css";
</style>
